package com.cjjd.c.base;

import android.support.v4.app.FragmentActivity;
import android.widget.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * ----------------------------------
 * Created by xyd on 2017/3/21.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public abstract class MyBaseAdapter extends BaseAdapter {

    public List data = new ArrayList<Object>();
    public FragmentActivity mContext;

    public MyBaseAdapter(FragmentActivity mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void setData(List listData) {
        if (listData == null){
            throw  new NullPointerException("list data cannot be null");
        }
        this.data = listData;
    }

    public void resetData(List listData) {
        if (listData == null){
            throw  new NullPointerException("list data cannot be null");
        }
        this.data = null;
        this.data = listData;
    }


}
